import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/viewmodel/food/single_food_menu_view_model.dart';

import '../../net/response/food/site_list_data.dart';

class SingleFoodMenuPage extends BaseStatefulMvvmWidget {
  final String orderType;
  final String date;
  final SiteListData siteId;
  final PickerDataWithIdModel foodTime;
  final PickerDataWithIdModel userWay;
  final int useNumber;

  SingleFoodMenuPage(
      {required this.orderType,
      required this.date,
      required this.siteId,
      required this.foodTime,
      required this.useNumber,
      required this.userWay});

  @override
  State<StatefulWidget> createState() => _SingleFoodMenuState();
}

class _SingleFoodMenuState
    extends BaseMvvmState<SingleFoodMenuViewModel, SingleFoodMenuPage> {
  @override
  Widget buildLoadingContentView() {
    return Column(
      children: [
        ///菜单内容
        Row(
          children: [
            viewModel
                .menuTypeWidget().setWeight(1),
            viewModel.foodMenuWidget().setWeight(3)
          ],
        ).setWeight(1),

        ///底部金额、提交按钮
        viewModel.bottomWidget()
      ],
    );
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      backgroundColor: Color(0xfff1f1f1),
      appBar: AppBar(
        title: Text("菜单列表"),
      ),
      body: loadingContentWidget,
    );
  }

  @override
  SingleFoodMenuViewModel createViewModel() {
    return SingleFoodMenuViewModel(context,
        site: widget.siteId,
        orderType: widget.orderType,
        date: widget.date,
        useNumber: widget.useNumber,
        foodTime: widget.foodTime,userWay: widget.userWay);
  }

  @override
  void onRetryClick() {
    viewModel.requestRefresh();
  }
}
